extends "res://ui/msgBase/msgBase.gd"

var btn = null
onready  var grid = $ScrollContainer / GridContainer
var utils = globalData.infoDs["g_azurlaneUtils"]
var base = globalData.infoDs["g_azurlaneBase"]
var talentSelItemScript = load(self.get_script().get_path().get_base_dir() + "/azurTalentSelItem.gd")
var talentLvScript = load(self.get_script().get_path().get_base_dir() + "/azurTalentLvMsg.gd")
func _ready():
	pass
	
func init(btn):
	for i in talentData.infos:
		if sys.main.player.talentDs.has(i.id) == false:
			var bt = preload("res://ui/talentSelMsg/item.tscn").instance()
			utils.changeScript(bt, talentSelItemScript)
			bt.init(i.id)
			grid.add_child(bt)
			bt.connect("onXuexi", self, "runXuexi")
	self.btn = btn
	popup()

	
	
func initTupu():
	for i in talentData.infos:
		var bt = preload("res://ui/talentSelMsg/item.tscn").instance()
		utils.changeScript(bt, talentSelItemScript)
		bt.initTupu(i.id)
		grid.add_child(bt)
		bt.connect("onXuexi", self, "upLv")
	self.btn = btn
	$Label.show()
	upP()
	talentData.connect("changeP", self, "upP")
	popup()

func runXuexi(talent):
	btn.xueXi(talent)
	queue_free()

func upLv(talent):
	var msg = sys.newMsg("talentLvMsg")
	utils.changeScript(msg, talentLvScript)
	msg.init(talent)
	
func upP():
	$Label.text = "至纯晶钻：%d" % base.getSetting("diamonds", 0)
